(function(window){
	window.loadTime=loadTime;
	function loadTime(options){
		//在画布右上角绘制文字
		this.ctx=options.ctx;
		this.text='';
		
		//绘制文字的位置
		this.x=this.ctx.canvas.width;
		this.y=0;
		
		// 记录游戏的运行总时长
        this.gameRunTime = 0;
	}
	loadTime.prototype={
		constructor:loadTime,
		draw:function(){
			 this.ctx.save();
			 
			this.ctx.font="900 20px 微软雅黑";
			this.ctx.textAlign="right";
			this.ctx.textBaseline="top";
			this.ctx.fillStyle="pink";
			this.ctx.fillText(this.text,this.x,this.y)
			
			this.ctx.restore();
		},
		update:function(delaySecond){
			this.gameRunTime+=delaySecond;
			//将上面的秒值转换为时分秒
			var hours=Math.floor(this.gameRunTime/3600);
			var minutes=Math.floor(this.gameRunTime%3600/60);
			var seconds=Math.floor(this.gameRunTime%60);
			hours=hours<10?"0"+hours:hours;
			minutes=minutes<10?"0"+minutes:minutes;
			seconds=seconds<10?"0"+seconds:seconds;
			this.text="计时："+hours+":"+minutes+":"+seconds;
		}
	}
}(window))
